<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/08/18 0018
 * Time: 15:04:31
 */
namespace app\admin\Controller;
use app\common\controller\Curt;
use think\Db;

class Income extends Curt{
    public function getall()
    {
        $keyword=trim(input('get.keyword'));
        if($keyword){
            $where['b.user_realname']=['like','%'.$keyword.'%'];//模糊查询or可以一个条件中写多个字段以‘|’分开
            $this->assign('keyword',$keyword);
        }
        $i_state=trim(input('get.i_state'));
        if($i_state){
            $where['a.i_state']=$i_state;
            $this->assign('i_state',$i_state);
        }
        $where['a.status']=1;
        $list=Db::name('income')->alias('a')
            ->join('ec_user b','a.user_id=b.id',left)
            ->where($where)
            ->field('a.*,b.user_realname')
            ->order('a.id desc')
            ->paginate();

        $page = $list->render();
        $listinfo=$list->toArray();
        $this->assign(
            ['income'=>$listinfo['data']],
            ['page'=>$page]
        );

    }

}